home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
001-100
/
001-025
/
020
/
hash
/
hash.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-17
|
533b
|
36 lines
main( argc, argv )
int argc;
char **argv;
{
if( argc != 2 ) {
printf( "Usage: %s <name>\n", argv[0] );
exit( 1 );
}
printf( "hash is %ld\n", (hash( argv[1] ) % 72) + 6 );
}
hash( s )
unsigned char *s;
{
int i;
int res;
unsigned char *sp;
unsigned c;
res = strlen( s );
for( i = 1, sp = s; *sp; i++, sp++ ) {
c = *sp;
if( c >= 'a' && c <= 'z' ) {
c = c - 'a' + 'A';
}
res = ((res * 13 + c ) & 0x7ff);
}
return( res );
}